﻿using System;

namespace DuckFlyWithInterface
{
    abstract class Duck
    {
        public string Name { get; set; }
        public void Display()
        {
            Console.WriteLine("这是一只{0}", Name);
        }
        // 飞行行为相关
        public IFlyBehavior flyBehavior { get; set; }
        public void performFly()
        {
            flyBehavior.Fly();
        }
        public void changeFlyBehavior(IFlyBehavior fl)
        {
            flyBehavior = fl;
        }

        // 叫声行为相关
        public IQuackBehavior quackBehavior { get; set; }
        public void performQuack()
        {
            quackBehavior.Quack();
        }
        public void changeQuackBehavior(IQuackBehavior qb)
        {
            quackBehavior = qb;
        }

        // 游泳行为相关
        public ISwimBehavior swimBehavior { get; set; }
        public void performSwim()
        {
            swimBehavior.Swim();
        }
        public void changeSwimBehavior(ISwimBehavior sb)
        {
            swimBehavior = sb;
        }

    }

    class Shelduck : Duck
    {
        public Shelduck()
        {
            Name = "Shelduck";
            flyBehavior = new FlyWithWings();
            quackBehavior = new NormalQuack();
            swimBehavior = new NormalSwim();
        }
    }

    class RedheadDuck : Duck
    {
        public RedheadDuck()
        {
            Name = "RedheadDuck";
            flyBehavior = new FlyWithWings();
            quackBehavior = new LoudQuack();
            swimBehavior = new FastSwim();
        }
    }

    class RobberDuck : Duck
    {
        public RobberDuck()
        {
            Name = "RobberDuck";
            flyBehavior = new FlyWithNoWay();
            quackBehavior = new Squeak();
            swimBehavior = new FloatOnly();
        }
    }
}